package com.heiyanquan.security.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author dingaolin
 * @Date: 2017/12/7 0007.
 */
@Aspect
@Component
public class TimeAspect {

    @Around("execution(* com.heiyanquan.security.controller.UserController.*(..))")
    public Object handleControllerMethod(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("TimeAspect start");
        long start = System.currentTimeMillis();

        Object object = proceedingJoinPoint.proceed();
        Object[] args = proceedingJoinPoint.getArgs();
        for (Object arg : args) {
            System.out.println("arg is " + arg);
        }

        System.out.println("MyThirdTimeFilter 耗時：" + (System.currentTimeMillis() - start));
        System.out.println("TimeAspect end");
        return object;
    }


}
